package com.jp.algorithm.stack;

public class MyStack {

    private Object[] array;
    private int top = -1;

    public MyStack(int capacity) {
        this.array = new Object[capacity];
    }

    public void push(Object a) {
        if (top == array.length) {
            return;
        }
        array[++top] = a;

    }

    public Object pop() {
        if (top == -1)
            return null;
        return array[top--];
    }

    public void print() {
        while (top != -1) {
            System.out.println("Object:" + pop());
        }
    }

    public static void main(String[] args) {
        MyStack stack = new MyStack(10);
        stack.push("a");
        stack.push("b");
        stack.push("c");
        stack.push("d");

        stack.print();
    }
}
